package com.imooc.advices;

import com.imooc.error.BusinessException;
import com.imooc.result.ApiResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 异常处理器
 */
@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(BusinessException.class)
    public ApiResult<?> businessExceptionAdvice(BusinessException e) {
        return ApiResult.fail(e.getCode(), e.getMsg());
    }

}
